package com.fly.domain;

import com.fly.persistence.DataEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Fly
 * @Description
 * @Date Created in 11:00 2018/1/24
 * @Modified by
 */
@Entity
@Table(name = "sys_menu")
public class Menu extends DataEntity<Menu>{

    /**
     * 父ID
     */
    private Long parentId;

    /**
     * 所有父ID
     */
    private String parentIds;

    /**
     * 菜单名称
     */
    @Size(max = 20)
    @NotNull(message = "菜单名不能为空")
    @Column(nullable = false, length = 20)
    private String name;
    /**
     * 连接地址
     */
    private String href;
    /**
     * 权限标识
     */
    private String permission;

    @Transient
    private List<Menu> children = new ArrayList<>();


    public List<Menu> getChildren() {
        return children;
    }

    public void setChildren(List<Menu> children) {
        this.children = children;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getParentIds() {
        return parentIds;
    }

    public void setParentIds(String parentIds) {
        this.parentIds = parentIds;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHref() {
        return href;
    }

    public void setHref(String href) {
        this.href = href;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    @Override
    public String toString() {
        return "Menu{" +
                "parentId=" + parentId +
                ", parentIds='" + parentIds + '\'' +
                ", name='" + name + '\'' +
                ", href='" + href + '\'' +
                ", permission='" + permission + '\'' +
                ", children=" + children +
                '}';
    }
}
